PHP: What's the best way to check equality of $_SERVER['HTTP_REFERER'] ?

Posted by Hank on Stack Overflow See other posts from Stack Overflow or by Hank
Published on 2010-04-05T19:39:18Z Indexed on 2010/04/05 19:43 UTC
Read the original article Hit count: 151

Filed under:
|

I have a PHP script that checks the HTTP Referer.

if ($_SERVER['HTTP_REFERER'] == 'http://www.example.com/') {...}

However, this seems inherintly unsafe ... because what happens if the user goes to 'http://example.com/' or 'http://www.ExaMple.com' (both of which don't match the equality test).

Question: what's a better equality test to ensure that the HTTP Referer is coming from 'example.com' ?

© Stack Overflow or respective owner

Related posts about php

Related posts about web-development